package com.medicinemanager.ui;

import com.example.medicinemanager.R;
import com.medicinemanager.app.MedicineApp;
import com.medicinemanager.bean.Medicineinfo;

import android.content.Intent;
import android.os.Bundle;
import android.widget.EditText;
import android.widget.TextView;

public class ShowInformationActivity extends BaseActivity{
	private TextView mTxId = null;
	private TextView mTxName = null;
	private TextView mTxNumber = null;
	private TextView mTxPerson = null;
	private TextView mTxPersonid = null;
	private Intent mExtraIntent = null;
	private MedicineApp mMedicineApp = null;
	public void onCreate(Bundle savedInstanceState){
		super.onCreate(savedInstanceState);
		setContentView(R.layout.activity_show_information);
		mExtraIntent = getIntent();
		
		initTextVIew();
		
		
	}
	
	private void initTextVIew(){ 
		mMedicineApp = (MedicineApp) getApplication();
		mTxId = (TextView) findViewById(R.id.tx_id);
		mTxName = (TextView) findViewById(R.id.tx_name);
		mTxNumber = (TextView) findViewById(R.id.tx_number);
		mTxPerson = (TextView) findViewById(R.id.tx_person);
		mTxPersonid = (TextView) findViewById(R.id.tx_personid);
		showData();
	}
	
	private void showData(){
		if(mExtraIntent != null){
			int index = mExtraIntent.getIntExtra("medicine", 0);
			mTxId.setText("ID: " + ((Medicineinfo)mMedicineApp.getMedicines().get(index)).getId());
			mTxNumber.setText("NUMBER: " + String.valueOf(((Medicineinfo)mMedicineApp.getMedicines().get(index)).getNumber()));
			mTxPerson.setText("PERSON: " + ((Medicineinfo)mMedicineApp.getMedicines().get(index)).getPerson());
			mTxName.setText("NAME: " + ((Medicineinfo)mMedicineApp.getMedicines().get(index)).getName());
			mTxPersonid.setText("PERSONID: " + ((Medicineinfo)mMedicineApp.getMedicines().get(index)).getPersonid());
		}
		
	}
	
	@Override
	public void gotoBack() {
		// TODO Auto-generated method stub
		Intent intent = new Intent();
		intent.setClass(ShowInformationActivity.this, ManagerMedicineActivity.class);
		ShowInformationActivity.this.startActivity(intent);
	}

	@Override
	public void gotoAhead() {
		// TODO Auto-generated method stub
		
	}
	
}
